cmake_minimum_required(VERSION 3.20)

project(ODVLib 
    VERSION 2.0.0
    LANGUAGES CXX
)

set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "项目根目录: ${PROJECT_ROOT_DIR}")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")    

# Qt5
set(CMAKE_AUTOMOC ON)
set(Qt5_MODULES
        Core
        Gui
        Widgets
        )
set(CMAKE_PREFIX_PATH ${Qt5_DIR})
find_package(Qt5 COMPONENTS ${Qt5_MODULES} REQUIRED)
if (Qt5_FOUND)
    foreach (Qt5_MODULE ${Qt5_MODULES})
        include_directories(${Qt5${Qt5_MODULE}_INCLUDE_DIRS})
    endforeach ()
else ()
    message(WARNING "Qt5 Not Found!")
endif ()

# python
find_package(Python3 COMPONENTS Interpreter Development)
message(STATUS "Python3_INCLUDE_DIRS:  ${Python3_INCLUDE_DIRS}")
message(STATUS "Python3_LIB_DIRS:  ${Python3_LIBRARY_DIRS}")

# pybind11
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pybind11)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/pybind11/include)

# src
add_subdirectory(src)

set(OUT_BIN_DIR ${CMAKE_BINARY_DIR}/bin)
if(NOT EXISTS ${OUT_BIN_DIR})
    file(MAKE_DIRECTORY ${OUT_BIN_DIR})
endif()